class Admin::OffsController < AdminController

  before_filter :load_user

  def new
    @off = Off.new
  end

  def create
    @off = Off.new params[:off].merge({ :user_id => @user.id })
    success = @off && @off.save
    flash[:notice] = success && @off.errors.empty? ? t(:off_created) : t(:error_off_creation)
    redirect_to :back
  end
  
  def update
    object
    success = @off.update_attributes(params[:off])
    flash[:notice] = success && @off.errors.empty? ? t(:off_updated) : t(:error_off_update)
    redirect_to :back
  end

  destroy.wants.html { redirect_to :back }

  private

  def collection
    @offs ||= @user.offs
  end

  def object
    @off ||= Off.find(params[:id])
  end

  def load_user
    @user ||= User.find(params[:user_id])
  end

  def model_name
    'off'
  end

end
